Creating a Dictionary using built-in function dict()

39

# welcome to softhunt.net
# Creating an empty Dictionary
Dictionary = {}
print("Empty Dictionary: ")
print(Dictionary)

# Creating a Dictionary
# with Dictionary() method
Dictionary = dict({0: 'Softhunt', 1: '.net', 2: 'By', 3: 'Ranjeet'})
print("\nDictionary with the use of dict(): ")
print(Dictionary)

# Creating a Dictionaryionary
# with each item as a Pair
Dictionary = dict([(0, 'Ranjeet'), (1, 'Kumar'), (2, 'Andani')])
print("\nDictionary with each item as a pair: ")
print(Dictionary)

Comments

Submit
0 Comments